from marshmallow import fields
from gis.common.django_ext.forms import PaginationSchema, BaseSchema, EnumField, ExportSchema
from itpay.core.agency.const import AgencyType, AgencyOrderStatusType


class ListAgencyRechargeListSchema(ExportSchema):
    id = fields.Integer()
    agency_type = EnumField(AgencyType)
    status = EnumField(AgencyOrderStatusType)
    parent_id = fields.Integer()
    agency_id = fields.Integer()
    agency_name = fields.String()
    parent_name = fields.String()
    created_at_begin = fields.DateTime()
    created_at_end = fields.DateTime()
    updated_at_begin = fields.DateTime()
    updated_at_end = fields.DateTime()


class RechargeReportListSchema(PaginationSchema):
    agency_name = fields.String()
    mch_id = fields.Integer()
    mch_name = fields.String()
    parent_name = fields.String()
    start_at = fields.DateTime()
    end_at = fields.DateTime()


class TtlRechargeReportSchema(BaseSchema):
    agency_name = fields.String()
    mch_id = fields.Integer()
    parent_name = fields.String()


class AgencyReportExportSchema(PaginationSchema):
    agency_id = fields.Integer()
    agency_name = fields.String()
    mch_id = fields.Integer()
    parent_name = fields.String()
    start_at = fields.DateTime()
    end_at = fields.DateTime()


class AgencyStatsReportSchema(ExportSchema):
    agency_ids = fields.String()
    mch_ids = fields.String()
    parent_ids = fields.String()
    parent_name = fields.String()
    time_range = fields.String()
    sort_by = fields.String()
    user_type = fields.String()


class InnerAgencyStatsReportSchema(ExportSchema):
    mch_ids = fields.String()
    parent_name = fields.String()
    time_range = fields.String()
    sort_by = fields.String()
    user_type = fields.String()


class AgencyOrderChangeStatusSchema(BaseSchema):
    reason = fields.String(missing='')
